<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="../../css/weui.min.css" />
		<link rel="stylesheet" type="text/css" href="../../css/jquery-weui.min.css" />
		<link rel="stylesheet" type="text/css" href="../../css/login.css" />
		<link rel="stylesheet" type="text/css" href="https://at.alicdn.com/t/font_425307_aq150n9pewcj714i.css" />
		<title>设置新密码</title>
		<script src="../../js/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/jquery-weui.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../../js/baseConfig.js" type="text/javascript" charset="utf-8"></script>
	</head>

	<body>
		<!--<div id="header">

		</div>-->
		<div class="weui-cells weui-cells_form" style="margin-top: 0;">
			<div class="weui-cell">
				<div class="weui-cell__hd"><label class="weui-label">新密码</label></div>
				<div class="weui-cell__bd">
					<input class="weui-input psd" type="password" pattern="[0-9]*" placeholder="请输入密码">
				</div>
			</div>
			<div class="weui-cell ">
				<div class="weui-cell__hd">
					<label class="weui-label">重复新密码</label>
				</div>
				<div class="weui-cell__bd">
					<input class="weui-input newPsd" type="password" placeholder="请确认新密码">
				</div>
			</div>
		</div>
		<div class="demos-content-padded" style="margin-top: 1.55rem;">
			<a href="javascript:;" class="weui-btn weui-btn_primary confirm_psd" style="background: #28C81E;">确定</a>
		</div>
	</body>
	<script type="text/javascript">
		$(document).ready(function() {
			baseConfig.historyBack()
//			$("#header").load('../common/header.html', function() {
//				$(".header-title").css("background", "#fff")
//				$(".header-title span").html("设置新密码")
//				$("#header .iconfont").css("display", "inline-block")
//				$(".header-title .left").on("click", function() {
//					history.back()
//				})
//			});
			var phone = baseConfig.GetQueryString("phone")
			$('.confirm_psd').on("click", function() {
				var psd = $(".psd").val()
				var newPsd = $(".newPsd").val()
				if(!psd || !newPsd) {
					$.toptip('密码输入不全', 1200, 'error');
				} else {
					if(psd != newPsd) {
						$.toptip('两次密码输入不一致', 1200, 'error');
					} else {
						$.ajax({
							type: "get",
							url: baseConfig.localHttp + "weChatApi/login/resetPassword",
							async: true,
							data: {
								newPwd: psd,
								newPwd2: newPsd,
								phone: phone
							},
							success: function(data) {
								if(data.code == 100) {
									$.toast("重置密码成功", function() {
										window.location.href = "login.html"
									});
								} else {
									$.toptip(data.content, 1200, 'error');
								}
							},
							error: function(data) {
									
							}
						});
					}
				}

			})
		})
	</script>

</html>